package 剑指offer;


/*
 * Author：江松
 * Date：2023/3/5 10:42
 *
 *
 * 包含min函数的栈：2个栈，一个栈专门存最小元素
 */

import java.util.Stack;

public class Main12 {
    Stack<Integer>stack=new Stack<>();
    Stack<Integer>minStack=new Stack<>();
    public void push(int node) {
        stack.push(node);
        if(minStack.isEmpty()||node<minStack.peek()){
            minStack.push(node);
        }else{
            minStack.push(minStack.peek());
        }
    }

    public void pop() {
        stack.pop();
        minStack.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int min() {
        return minStack.peek();
    }
    public static void main(String[] args) {

    }
}
